#include <iostream>
using std::cout;
using std::endl;

class Base{
public:
    Base(){
        cout << "Base()" << endl;
    } 

    Base(long base)
    : _base(base)
    { cout << "Base(long)" << endl; }

    ~Base(){ cout << "~Base()" << endl; }
private:
    long _base;
};

class Test{
public:
    Test(long test)
    : _test(test)
    { cout << "Test(long) " << endl; }
    ~Test(){ cout << "~Test()" << endl; }
private:
    long _test;
};


class Derived
: public Base
{
public:
    //派生类没有显式调用基类的构造时，会默认调用基类的默认构造
    Derived(long a,long b,long c)
    : Base(a) //调用基类的构造，写的是基类的类名
    , _t1(b) //调用的是Test类的构造，写的是对象成员的名字（初始化对象成员）
    , _derived(c)
    {
        cout << "Derived(long * 3)" << endl;
    }
    ~Derived(){ cout << "~Derived()" << endl; }
private:
    Test _t1;
    long _derived;
};

void test0(){
    Derived _d1(1,2,3);
}

int main(void){
    test0();
    return 0;
}
